﻿using System;
using System.Threading;

namespace PixivVideo.Currency
{
    internal class ThreadSleep
    {/// <summary>
     /// 设置睡眠时间
     /// </summary>
     /// <param name="MaxTime"></param>
        public void SetClock(int MaxTime)
        {
            SetClock(0, MaxTime);
        }/// <summary>

        /// 设置睡眠时间
        /// </summary>
        /// <param name="MinTime"></param>
        /// <param name="MaxTime"></param>
        public void SetClock(int MinTime, int MaxTime)
        {
            int SleepRandom = new Random().Next(MinTime, MaxTime);

            SleepLog(SleepRandom);
        }

        private static void SleepLog(int SleepTime)
        {
            while (SleepTime >= 0)
            {
                Console.WriteLine(string.Format("{0} 程序休眠中，距离唤醒还有{1}秒。", DateTime.Now.ToString(), SleepTime--), 0, 0);

                Thread.Sleep(1000);
            }
        }
        /// <summary>
        /// 毫秒休眠
        /// </summary>
        /// <param name="SleepTime"></param>
        public void SetClockWithMillisecond(int SleepTime) {
            Thread.Sleep(SleepTime);
        }
    }
}